//
//  KLIdeRecomendViewController.m
//  KunLun
//
//  Created by Mac on 2017/11/27.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "KLIdeRecomendViewController.h"
#import "KLNormalCollectionViewCell.h"
#define collectionViewItemHeight 240
@interface KLIdeRecomendViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property(nonatomic, strong) STSegementButton                     *segementButton;
@property(nonatomic, strong) UICollectionView                     *collectionView;
@end

@implementation KLIdeRecomendViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"平台推荐";
    [self configSubView];
    // Do any additional setup after loading the view.
}

#pragma mark --subView
- (void)configSubView{
    
    self.segementButton = [[STSegementButton alloc] initWithFrame:CGRectMake(0, 64, UIScreenWidth, 44) andTitle:@[@"各地特产",@"民车出租",@"今日特价",@"菜园子"] handle:^(STSegementButton *sender) {
        
    }];
    self.segementButton.backgroundColor = [UIColor whiteColor];
    self.segementButton.lineSelectedColor = KL_BlueBackGroundColor;
    self.segementButton.butTitleSelectedColor = KL_BlueBackGroundColor;
    self.segementButton.butTitleColor = KL_secendTextColor;
    self.segementButton.lineColor = [UIColor whiteColor];
    self.segementButton.cureentIndex = 0;
    self.segementButton.autoMoveWithClic = YES;
    
    [self.view addSubview:self.segementButton];
    self.tableView.top = self.tableView.top + self.segementButton.height;
    self.tableView.height = self.tableView.height - self.segementButton.height;
    
    //collectionView
    UICollectionViewFlowLayout * flow = [UICollectionViewFlowLayout new];
    flow.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
    flow.minimumLineSpacing = 0;
    flow.minimumInteritemSpacing = 0;
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.segementButton.bottom + 10, UIScreenWidth, UIScreenHeight - self.segementButton.height - 10 - 64) collectionViewLayout:flow];
    self.collectionView.backgroundColor = KL_backgroundColor;
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    [self.collectionView registerClass:[KLNormalCollectionViewCell class] forCellWithReuseIdentifier:@"item"];
    [self.view addSubview:self.collectionView];
}
#pragma --mark UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 20;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(UIScreenWidth/2 - 20, collectionViewItemHeight);
}
- (UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    KLNormalCollectionViewCell * item =[collectionView dequeueReusableCellWithReuseIdentifier:@"item" forIndexPath:indexPath];
//    item.model = self.collectionViewData[indexPath.row];
    return item;
}
#pragma --mark UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
//    GHGoodModel * model = self.collectionViewData[indexPath.row];
//    [self goDetailVcWithModel:model];
    [self.navigationController pushViewController:[KLGoodDetailViewController new] animated:YES];
    [self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
}
@end
